package cn.microven.mindmap.oprations;

import cn.microven.mindmap.components.node.AbstractMapNode;
import cn.microven.mindmap.struture.MindMap;
import javafx.scene.control.ComboBox;

public class ChangeFontTypeOperation implements Operation {

    public ComboBox fontList;

    public String newFont;

    public String oldFont;

    public AbstractMapNode node;

    public ChangeFontTypeOperation(String newFont,String oldFont,AbstractMapNode node){
            this.oldFont = oldFont;
            this.newFont = newFont;
            this.node = node;
    }

    @Override
    public void start(boolean isRedo) {
        /*//获取字体样式
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        //返回一个数组，其中包含针对指定语言环境本地化的此 GraphicsEnvironment中所有字体系列的名称。
        String[] fontNames = ge.getAvailableFontFamilyNames();
        List<String> textList = new ArrayList(fontNames.length);

        for(int i = 0; i < fontNames.length; ++i) {
            textList.add(new String(fontNames[i]));
        }
        //添加字体进入ComboBox
        this.fontList.setItems(FXCollections.observableArrayList(textList));*/

        node.setFontFamily(newFont);
        if (!MindMap.getInstance().isUndoing() && !MindMap.getInstance().isRedoing()) {
            MindMap.addOperation(this);
        }
    }

    @Override
    public void undo() {
        node.setFontFamily(oldFont);
    }
}
